package com.foreknow.demo5;

/**
 * 构造器(构造函数/构造方法)
 * 构造器如何初始化变量
 */
public class ConstrctorDemo {

    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ConstrctorDemo(String name,int age) {
        this.name = name;
        this.age = age;
    //        System.out.println("构造器的作用是初始化的......");
    }

    public static void main(String[] args) {
        ConstrctorDemo c = new ConstrctorDemo("tom",20);
        System.out.println(c.getName());

    }


}
